package com.qr.service.wmyh.impl;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.mapping.ResultMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.krui.helper.db.DBHelper;
import cn.krui.helper.db.DataPage;
import com.qr.bean.wmyh.JbrUserAmountRecharge;
import com.qr.bean.wmyh.JbrUserAmountRechargeView;
import com.qr.controller.WmyhBase;
import com.qr.mapper.wmyh.JbrUserAmountRechargeMapper;
import com.qr.mapper.wmyh.JbrUserAmountRechargeMapperView;
import com.qr.service.wmyh.JbrUserAmountRechargeService;
//import org.apache.dubbo.config.annotation.Service;

/**
 * @author: zc
 * email: zc8023zs@163.com
 * create_time: 2020/8/11 13:02:03
 */
@Service
//@Service(version = "1.0.0",group="dubbo")
public class JbrUserAmountRechargeServiceImpl implements JbrUserAmountRechargeService{
    @Autowired
    private JbrUserAmountRechargeMapper jbrUserAmountRechargeMapper;

    @Autowired
    private JbrUserAmountRechargeMapperView jbrUserAmountRechargeMapperView;
    
    @Autowired
    private DBHelper dbHelper;

    /**
     * 构造查询条件
     */
    private QueryWrapper<JbrUserAmountRecharge> InitWrapper(JbrUserAmountRecharge where){
        QueryWrapper<JbrUserAmountRecharge> whereWrapper = new QueryWrapper<JbrUserAmountRecharge>();
        if(where.getId()!=null){
			whereWrapper.eq("id",where.getId());
		}
        if(where.getUser_id()!=null){
			whereWrapper.eq("user_id",where.getUser_id());
		}
        if(where.getOrder_num()!=null){
			whereWrapper.eq("order_num",where.getOrder_num());
		}
        if(where.getRecharge_time()!=null){
			whereWrapper.eq("recharge_time",where.getRecharge_time());
		}
        if(where.getRecharge_price()!=null){
			whereWrapper.eq("recharge_price",where.getRecharge_price());
		}
        if(where.getStatus()!=null){
			whereWrapper.eq("status",where.getStatus());
		}
        if(where.getPay_type()!=null){
			whereWrapper.eq("pay_type",where.getPay_type());
		}
        if(where.getPay_serial_number()!=null){
			whereWrapper.eq("pay_serial_number",where.getPay_serial_number());
		}
        if(where.getPay_time()!=null){
			whereWrapper.eq("pay_time",where.getPay_time());
		}
        if(where.getNote()!=null){
			whereWrapper.eq("note",where.getNote());
		}
        return whereWrapper;
    }

    private QueryWrapper<JbrUserAmountRechargeView> InitWrapperView(JbrUserAmountRechargeView where){
        QueryWrapper<JbrUserAmountRechargeView> whereWrapper = new QueryWrapper<JbrUserAmountRechargeView>();
        if(where.getId()!=null){
			whereWrapper.eq("id",where.getId());
		}
        if(where.getUser_id()!=null){
			whereWrapper.eq("user_id",where.getUser_id());
		}
        if(where.getOrder_num()!=null){
			whereWrapper.eq("order_num",where.getOrder_num());
		}
        if(where.getRecharge_time()!=null){
			whereWrapper.eq("recharge_time",where.getRecharge_time());
		}
        if(where.getRecharge_price()!=null){
			whereWrapper.eq("recharge_price",where.getRecharge_price());
		}
        if(where.getStatus()!=null){
			whereWrapper.eq("status",where.getStatus());
		}
        if(where.getPay_type()!=null){
			whereWrapper.eq("pay_type",where.getPay_type());
		}
        if(where.getPay_serial_number()!=null){
			whereWrapper.eq("pay_serial_number",where.getPay_serial_number());
		}
        if(where.getPay_time()!=null){
			whereWrapper.eq("pay_time",where.getPay_time());
		}
        if(where.getNote()!=null){
			whereWrapper.eq("note",where.getNote());
		}
        return whereWrapper;
    }

    /**
     * 余额充值订单新增
     * @param model 余额充值订单实体
     * @return 影响行数
     */
	@Override
    public Integer add(JbrUserAmountRecharge model){
        return jbrUserAmountRechargeMapper.insert(model);
    }

    /**
     * 余额充值订单修改byid
     * @param model 余额充值订单实体
     * @return 影响行数
     */
	@Override
    public Integer update(JbrUserAmountRecharge model) {
        return jbrUserAmountRechargeMapper.updateById(model);
    }

    /**
     * 余额充值订单修改by条件
     * @param model 余额充值订单实体
     * @param where 余额充值订单条件
     * @return 影响行数
     */
	@Override
    public Integer update(JbrUserAmountRecharge model, Wrapper<JbrUserAmountRecharge> where) {
        return jbrUserAmountRechargeMapper.update(model, where);
    }

    /**
     * 余额充值订单修改by条件-自动封装Wrapper
     * @param model 余额充值订单实体
     * @return 影响行数
     */
	@Override
    public Integer update(JbrUserAmountRecharge model, JbrUserAmountRecharge where) {
        Wrapper<JbrUserAmountRecharge> wrapper = InitWrapper(where);
        return update(model, wrapper);
    }

    /**
     * 余额充值订单修改bySQL *version_id = newVersion where version_id = oldVersion
     * @param fields 修改的数据 col1=xx,col2=yy
     * @param where 参数化条件 col1=#{col1}
     * @param params 条件参数 col1=xx
     * @return 影响行数
     */
	@Override
    public Integer update(Map<String, Object> fields, String where, Map<String, Object> params) {
        return dbHelper.update("jbr_user_amount_recharge", fields, where, params);
    }

    /**
     * 余额充值订单删除byid
     * @param id 余额充值订单主键
     * @return 影响行数
     */
	@Override
    public Integer del(int id) {
        return jbrUserAmountRechargeMapper.deleteById(id);
    }

    /**
     * 余额充值订单删除by条件
     * @param where 余额充值订单条件
     * @return 影响行数
     */
	@Override
    public Integer del(Wrapper<JbrUserAmountRecharge> where) {
        return jbrUserAmountRechargeMapper.delete(where);
    }

    /**
     * 余额充值订单删除by条件-自动封装Wrapper
     * @param where 余额充值订单条件
     * @return 影响行数
     */
    @Override
    public Integer del(JbrUserAmountRecharge where) { 
        Wrapper<JbrUserAmountRecharge> wrapper = InitWrapper(where);
        return del(wrapper);
    }

    /**
     * 余额充值订单批量删除byid
     * @param ids 余额充值订单主键集合
     * @return 影响行数
     */
	@Override
    public Integer del(List<Integer> ids){
        return jbrUserAmountRechargeMapper.deleteBatchIds(ids);
    }

    /**
     * 余额充值订单批量删除bymap条件
     * @param map 余额充值订单map条件
     * @return 影响行数
     */
	@Override
    public Integer del(Map<String,Object> map){
        return jbrUserAmountRechargeMapper.deleteByMap(map);
    }

    /**
     * 余额充值订单详情byid
     * @param id 余额充值订单主键
     * @return 余额充值订单详情
     */
	@Override
    public JbrUserAmountRechargeView info(int id){
        return jbrUserAmountRechargeMapperView.selectById(id);
    }

    /**
     * 余额充值订单详情by条件
     * @param where 余额充值订单条件
     * @return 余额充值订单详情
     */
	@Override
    public JbrUserAmountRechargeView info(Wrapper<JbrUserAmountRechargeView> where){
        return jbrUserAmountRechargeMapperView.selectOne(where);
    }

    /**
     * 余额充值订单详情by条件-自动封装Wrapper
     * @param where 余额充值订单条件
     * @return 余额充值订单详情
     */
	@Override
    public JbrUserAmountRechargeView info(JbrUserAmountRechargeView where) {
        Wrapper<JbrUserAmountRechargeView> wrapper = InitWrapperView(where);
        return info(wrapper);
    }

    /**
     * 余额充值订单详情bySQL
     * @param columns  列名col1,col2,col3^
     * @param where 条件 col1=#{col1}
     * @param params col1:xx
     * @param mappings col1->col1
     * @return
     */
	@Override
    public JbrUserAmountRecharge info(String columns, String where, Map<String, Object> params, ResultMapping mappings) {
        return dbHelper.selectOne(columns, "jbr_user_amount_recharge", where, params, JbrUserAmountRecharge.class, mappings);
    }

    /**
     * 余额充值订单批量查询byid
     * @param ids 余额充值订单主键集合
     * @return 余额充值订单列表
     */
	@Override
    public List<JbrUserAmountRechargeView> select(List<Integer> ids){
        return jbrUserAmountRechargeMapperView.selectBatchIds(ids);
    }

    /**
     * 余额充值订单批量查询by条件
     * @param where 余额充值订单条件
     * @return 余额充值订单列表
     */
	@Override
    public List<JbrUserAmountRechargeView> select(Wrapper<JbrUserAmountRechargeView> where){
        return jbrUserAmountRechargeMapperView.selectList(where);
    }

    /**
     * 余额充值订单批量查询by条件-自动封装Wrapper
     * @param where 余额充值订单条件
     * @return 余额充值订单列表
     */
    @Override
    public List<JbrUserAmountRechargeView> select(JbrUserAmountRechargeView where) {
        Wrapper<JbrUserAmountRechargeView> wrapper = InitWrapperView(where);		
        return select(wrapper);
    }

    /**
     * 余额充值订单批量查询bymap条件
     * @param map 余额充值订单map条件
     * @return 余额充值订单列表
     */
	@Override
    public List<JbrUserAmountRechargeView> select(Map<String,Object> map){
        return jbrUserAmountRechargeMapperView.selectByMap(map);
    }

    /**
     * 余额充值订单批量查询b条件分页
     * @param page 分页条件
     * @param where 查询条件
     * @return
     */
	@Override
    public IPage<JbrUserAmountRechargeView> select(IPage<JbrUserAmountRechargeView> page, Wrapper<JbrUserAmountRechargeView> where){
        return jbrUserAmountRechargeMapperView.selectPage(page, where);
    }

    /**
     * 余额充值订单批量查询b条件分页
     * @param page 分页条件
     * @param where 查询条件
     * @return
     */
    @Override
    public IPage<JbrUserAmountRechargeView> select(IPage<JbrUserAmountRechargeView> page, JbrUserAmountRechargeView where) {
		Wrapper<JbrUserAmountRechargeView> wrapper = InitWrapperView(where);		
        return select(page, wrapper);
    }

    /**
     * 余额充值订单查询记录数
     * @param where 查询条件
     * @return
     */
	@Override
    public Integer selectCount(Wrapper<JbrUserAmountRechargeView> where){
        return jbrUserAmountRechargeMapperView.selectCount(where);
    }

    /**
     * 余额充值订单查询记录数
     * @param where 查询条件
     * @return
     */
	@Override
    public Integer selectCount(JbrUserAmountRechargeView where){
		Wrapper<JbrUserAmountRechargeView> wrapper = InitWrapperView(where);
        return selectCount(wrapper);
    }

    /**
     * 余额充值订单批量查询bySQL条件分页
     * @param columns 列col1,col2,col3……
     * @param where 条件col1=#{col1} and col2=#{col2}
     * @param orderBy 排序字段
     * @param params 参数化 col1=xx
     * @param pageNumber 分页页码
     * @param pageSize 每页行数
     * @param mappings 查询列和实体映射
     * @return 分页之后的数据含总行数
     */
	@Override
    public DataPage<JbrUserAmountRechargeView> select(String columns, String where, String orderBy, Map<String, Object> params, int pageNumber, int pageSize, ResultMapping mappings){
        return dbHelper.select(columns, "jbr_user_amount_recharge", where, orderBy, params, pageNumber, pageSize, JbrUserAmountRechargeView.class,mappings);
    }

    /**
     * 余额充值订单批量查询bySQL条件
     * @param columns 列col1,col2,col3……
     * @param where 条件col1=#{col1} and col2=#{col2}
     * @param params 参数化 col1=xx
     * @param mappings 查询列和实体映射
     * @return 栏目扩展列表
     */
	@Override
    public List<JbrUserAmountRechargeView> select(String columns, String where, Map<String, Object> params, ResultMapping mappings){
        return dbHelper.select(columns,"jbr_user_amount_recharge",where,params,JbrUserAmountRechargeView.class,mappings);
    }
}